package nio;

import org.junit.Test;

import java.nio.ByteBuffer;

public class NioTest
{
    @Test
    public void test()
    {
       String str = "abcde";
        ByteBuffer buf = ByteBuffer.allocate(1024);
        buf.put(str.getBytes());

        buf.flip();

        byte[] dst = new byte[buf.limit()];
        buf.get(dst, 0, 2);
        System.out.println(new String(dst,0,2));
    }
}
